﻿using LargeScreen.WPF.Base;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace LargeScreen.WPF.Models
{
    public class DeviceModel : NotifyBase
    {
		private float _temperature;

		public float Temperature
        {
			get { return _temperature; }
			set 
            { 
                SetProperty(ref _temperature, value);

                // Update min and max temperature based on the current value
                if (value < MinTemperature || float.IsNaN(MinTemperature)) MinTemperature = value;
                if (value > MaxTemperature || float.IsNaN(MaxTemperature)) MaxTemperature = value;
            }
        }

        private float _minTemperature = float.NaN;

        public float MinTemperature
        {
            get { return _minTemperature; }
            set { SetProperty(ref _minTemperature, value); }
        }


        private float _maxTemperature = float.NaN;

        public float MaxTemperature
        {
            get { return _maxTemperature; }
            set { SetProperty(ref _maxTemperature, value); }
        }


        private float _humidity;

        public float Humidity
        {
            get { return _humidity; }
            set 
            { 
                SetProperty(ref _humidity, value);

                if (value < MinHumidity || float.IsNaN(MinHumidity)) MinHumidity = value;
                if (value > MaxHumidity || float.IsNaN(MaxHumidity)) MaxHumidity = value;
            }
        }


        private float _minHumidity = float.NaN;

        public float MinHumidity
        {
            get { return _minHumidity; }
            set { SetProperty(ref _minHumidity, value); }
        }

        private float _maxHumidity = float.NaN;

        public float MaxHumidity
        {
            get { return _maxHumidity; }
            set { SetProperty(ref _maxHumidity, value); }
        }

        private float _brightness;

        public float Brightness
        {
            get { return _brightness; }
            set 
            { 
                SetProperty(ref _brightness, value);

                if (value < MinBrightness || float.IsNaN(MinBrightness)) MinBrightness = value;
                if (value > MaxBrightness || float.IsNaN(MaxBrightness)) MaxBrightness = value;
            }
        }


        private float _minBrightness = float.NaN;

        public float MinBrightness
        {
            get { return _minBrightness; }
            set { SetProperty(ref _minBrightness, value); }
        }

        private float _maxBrightness = float.NaN;

        public float MaxBrightness
        {
            get { return _maxBrightness; }
            set { SetProperty(ref _maxBrightness, value); }
        }

        public bool UseTemperatureSim { get; set; }
        public int MinTemperatureSim { get; set; } = -10;
        public int MaxTemperatureSim { get; set; } = 80;

        public bool UseHumiditySim { get; set; }
        public int MinHumiditySim { get; set; } = 0;
        public int MaxHumiditySim { get; set; } = 100;

        public bool UseBrightnessSim { get; set; }
        public int MinBrightnessSim { get; set; } = 0;
        public int MaxBrightnessSim { get; set; } = 100;
    }
}
